package cn.e4j.modular.crm.service.impl;

import cn.e4j.core.dto.Dtos;
import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.shiro.ShiroKit;
import cn.e4j.core.shiro.ShiroUser;
import cn.e4j.core.util.DateUtils;
import cn.e4j.core.util.InvokeUtil;
import cn.e4j.core.util.StringUtils;
import cn.e4j.modular.common.service.SysAuthorityService;
import cn.e4j.modular.crm.entity.MmrwT;
import cn.e4j.modular.crm.mapper.MmrwTMapper;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;

/**
 * <p>
 *  维修费用结算 服务实现类
 * </p>
 *
 * @author miaoyl
 * @since 2019-08-30
 */
@Service
public class MmrwTServiceImpl extends ServiceImpl<MmrwTMapper, MmrwT> {

    @Autowired
    public SysAuthorityService sysAuthorityService;

    @Transactional(readOnly = true)
    public List<Dto> getListData(Page<Object> page, Dto dto) {
        //客户权限
        dto.put("CUSTOMERS", sysAuthorityService.getCustomersAuthority(dto));
        //部门权限
        dto.put("ORGS", sysAuthorityService.getOrgsAuthority(dto));

//        List<Dto> listData = this.baseMapper.getMmrwlist(page, dto);
        List<Dto> listData = InvokeUtil.invokeBeanMethod("mmrwTMapper,getMmrwlist",page,dto);
        return listData;
    }

    @Transactional(readOnly = true)
    public List<Dto> getMmrhgData(Page<Object> page, Dto dto) {
        if(!StringUtils.isEmpty(dto.getString("STR"))){
            String[] str = dto.getString("STR").split(",");
            List<String> plist = Lists.newArrayList();
            for (String mmrh : str) {
                plist.add(mmrh);
            }
            dto.put("MMRH",plist);
        }
//        List<Dto> listData = this.baseMapper.getMmrhgData(page, dto);
        List<Dto> listData = InvokeUtil.invokeBeanMethod("mmrwTMapper,getMmrhgData",page, dto);
        return listData;
    }

    @Transactional(readOnly = true)
    public List<Dto> getMmrwData(Dto dto) {
        List<Dto> listData = this.baseMapper.getMmrwData(dto);
        return listData;
    }

    @Transactional(readOnly = true)
    public List<Dto> getMmrwAllData(Dto dto) {
//        List<Dto> listData = this.baseMapper.getMmrwAllData(dto);
        List<Dto> listData = InvokeUtil.invokeBeanMethod("mmrwTMapper,getMmrwAllData",dto);
        return listData;
    }

    /**
     * 归属法人开窗
     */
    @Transactional(readOnly = true)
    public List<Dto> getSysOrg(Page<Object> page, Dto dto) {
        List<Dto> listData = this.baseMapper.getSysOrg(page, dto);
        for(int i=0; i<listData.size(); i++){
            Dto MB002 = this.baseMapper.getMB002(listData.get(i).getString("BIZ_CODE"));
            if(MB002 != null){
                listData.get(i).put("BIZ_CODE_NAME", MB002.getString("MB002"));
            }else {
                listData.get(i).put("BIZ_CODE_NAME", "");
            }
        }
        return listData;
    }

    @Transactional(readOnly = true)
    public Dto getMB002(Dto dto) {
        Dto data = this.baseMapper.getMB002(dto.getString("MMRXPLANT"));
        return data;
    }

    @Transactional
    public void addData(List<MmrwT> mmrwTList) {
        ShiroUser shiroUser = ShiroKit.getUser();
        //增加新的明细
        String mmrwTime = DateUtils.formatDate(new Date(), "HH:mm:ss");
        for (int i = 0; i < mmrwTList.size(); i++) {
            MmrwT mmrw = mmrwTList.get(i);
            mmrw.setMMRWSENT(shiroUser.getDBC());
            mmrw.setMMRWSEQ(BigDecimal.valueOf(i+1));
            mmrw.setMMRWACTI("N");//未审核
            mmrw.setMMRWUSER(shiroUser.getID());
            mmrw.setMMRWGRUP(shiroUser.getORG_ID());
            mmrw.setMMRWDATE(LocalDate.now());
            mmrw.setMMRWTIME(mmrwTime);
            mmrw.setMMRWORIG(shiroUser.getORG_ID());
            mmrw.setMMRWORIU(shiroUser.getID());
            mmrw.setMMRWMLRGAL(mmrw.getMMRWLEGAL());
            mmrw.insert();
        }
    }

    @Transactional
    public void editData(List<MmrwT> mmrwTList) {
        ShiroUser shiroUser = ShiroKit.getUser();
        MmrwT mmrwTDel = new MmrwT();
        UpdateWrapper mmrwUpdateWrapper = new UpdateWrapper();
        mmrwUpdateWrapper.eq("MMRWSENT", shiroUser.getDBC());
        mmrwUpdateWrapper.eq("MMRWDOCNO", mmrwTList.get(0).getMMRWDOCNO());
        mmrwTDel.delete(mmrwUpdateWrapper);
        //增加新的明细
        String mmrwTime = DateUtils.formatDate(new Date(), "HH:mm:ss");
        for (int i = 0; i < mmrwTList.size(); i++) {
            MmrwT mmrw = mmrwTList.get(i);
            mmrw.setMMRWSENT(shiroUser.getDBC());
            mmrw.setMMRWSEQ(BigDecimal.valueOf(i+1));
            mmrw.setMMRWACTI("N");//未审核
            mmrw.setMMRWMODU(shiroUser.getID());
            mmrw.setMMRWDATE(LocalDate.now());
            mmrw.setMMRWTIME(mmrwTime);
            mmrw.setMMRWMLRGAL(mmrw.getMMRWLEGAL());
            mmrw.insert();
        }
    }

    @Transactional
    public void delete(MmrwT mmrwT) {
        ShiroUser shiroUser = ShiroKit.getUser();
        UpdateWrapper<MmrwT> mmrwTUpdateWrapper = new UpdateWrapper<>();
        mmrwTUpdateWrapper.eq("MMRWSENT", shiroUser.getDBC());
        mmrwTUpdateWrapper.eq("MMRWDOCNO", mmrwT.getMMRWDOCNO());
        mmrwTUpdateWrapper.eq("MMRWSEQ", mmrwT.getMMRWSEQ());
        mmrwT.delete(mmrwTUpdateWrapper);
    }

    @Transactional
    public void delDataBatch(List<MmrwT> mmrwTList) {
        ShiroUser shiroUser = ShiroKit.getUser();
        for (MmrwT mmrwT : mmrwTList) {
            UpdateWrapper<MmrwT> mmrwTUpdateWrapper = new UpdateWrapper<>();
            mmrwTUpdateWrapper.eq("MMRWSENT", shiroUser.getDBC());
            mmrwTUpdateWrapper.eq("MMRWDOCNO", mmrwT.getMMRWDOCNO());
            mmrwTUpdateWrapper.eq("MMRWSEQ", mmrwT.getMMRWSEQ());
            mmrwT.delete(mmrwTUpdateWrapper);
        }
    }

    @Transactional
    public void updateStatus(List<MmrwT> mmrwTList) {
        for (int i = 0; i < mmrwTList.size(); i++) {
            MmrwT mmrwT = mmrwTList.get(i);
            UpdateWrapper<MmrwT> mmrwTUpdateWrapper = new UpdateWrapper<>();
            mmrwTUpdateWrapper.eq("MMRWSENT", mmrwT.getMMRWSENT());
            mmrwTUpdateWrapper.eq("MMRWDOCNO", mmrwT.getMMRWDOCNO());
            mmrwT.update(mmrwTUpdateWrapper);
        }
    }

    @Transactional
    public Dto transferMmrghData(List<MmrwT> mmrwTList) {
        Dto outDto = Dtos.newDto();
        ShiroUser shiroUser = ShiroKit.getUser();
        String MMRWDOCNO = "PFYD" + DateUtils.getDate("yyyyMMddHHmmssSSS");
        /*String MMRWPLANT = "";
        String MMRWLEGAL = "";*/
        String MMRW005 = "";
        int count = 1;
        /*Dto inDto = Dtos.newDto();
        inDto.put("ID",shiroUser.getORG_ID());
        List<Dto> org = this.baseMapper.getOrg(inDto);
        if(org.size() > 0){
            MMRWPLANT = org.get(0).getString("BIZ_CODE");
            MMRWLEGAL = org.get(0).getString("ID");
        }
        inDto.put("MMRW017", shiroUser.getORG_ID());
        inDto.put("ENT", shiroUser.getDBC());
        List<Dto> mmrs002 = this.baseMapper.getMmrs002(inDto);
        if(mmrs002.size() > 0){
            MMRW005 = mmrs002.get(0).getString("mmrs002");
        }*/
        //edit by miaoyl 当前操作者，需修改为报工单中，报工工程师的人员姓名，仓库，以及所属组织
        for (int i = 0; i < mmrwTList.size(); i++) {
            MmrwT mmrwT = mmrwTList.get(i);
            Dto inDto = Dtos.newDto();
            inDto.put("GWAS002",mmrwT.getMMRW017());
            inDto.put("ENT", shiroUser.getDBC());
            List<Dto> gwas001 = this.baseMapper.getGwas001(inDto);
            if(gwas001.size() > 0){
                MMRW005 = gwas001.get(0).getString("GWAS001");
            }
            //获取归属法人及erp组织
            Dto qDto = Dtos.newDto();
            qDto.put("ID",mmrwT.getMMRW017());
            String MMRWPLANT = "";
            String MMRWLEGAL = "";
//            List<Dto> org = this.baseMapper.getOrg(inDto);
            List<Dto> org = InvokeUtil.invokeBeanMethod("mmrwTMapper,getOrg",qDto);
            if(org.size() > 0){
                MMRWPLANT = org.get(0).getString("BIZ_CODE");
                MMRWLEGAL = org.get(0).getString("ID");
            }
            mmrwT.setMMRWSENT(shiroUser.getDBC());
            mmrwT.setMMRWDOCNO(MMRWDOCNO);
            mmrwT.setMMRWDOCDATE(LocalDate.now());
            mmrwT.setMMRWSEQ(BigDecimal.valueOf(count));
            //mmrwT.setMMRW017(shiroUser.getORG_ID());
            //mmrwT.setMMRW016(shiroUser.getID());
            mmrwT.setMMRWPLANT(MMRWPLANT);
            mmrwT.setMMRWLEGAL(MMRWLEGAL);
            mmrwT.setMMRW005(MMRW005);
            mmrwT.setMMRWACTI("N");
            mmrwT.setMMRWUSER(shiroUser.getID());
            mmrwT.setMMRWGRUP(shiroUser.getORG_ID());
            mmrwT.setMMRWDATE(LocalDate.now());
            mmrwT.setMMRWTIME(DateUtils.formatDate(new Date(), "HH:mm:ss"));
            mmrwT.setMMRWORIG(shiroUser.getORG_ID());
            mmrwT.setMMRWORIU(shiroUser.getID());
            mmrwT.setMMRWMLRGAL(MMRWLEGAL);
            mmrwT.insert();
            count++;
        }
        outDto.put("docno", MMRWDOCNO);
        return outDto;
    }

    @Transactional(readOnly = true)
    public Dto getDBinfo1(String ID) {
        Dto listData = this.baseMapper.getDBinfo1(ID);
        return listData;
    }

    @Transactional(readOnly = true)
    public Dto getGwaz(String MMRWLEGAL) {
        Dto listData = this.baseMapper.getGwaz(MMRWLEGAL);
        return listData;
    }

    @Transactional(readOnly = true)
    public Dto getGwebData1(Dto inDto) {
        Dto listData = this.baseMapper.getGwebData1(inDto);
        return listData;
    }

    @Transactional(readOnly = true)
    public Dto getGwebData2(Dto inDto) {
        Dto listData = this.baseMapper.getGwebData2(inDto);
        return listData;
    }

    @Transactional
    public JSONArray transferERP(Dto inDto) {
        ShiroUser shiroUser = ShiroKit.getUser();
        String[] selectionIds = inDto.getString("datas").split(",");
        List list = Arrays.asList(selectionIds);
        JSONArray json = new JSONArray();
        Set set = new HashSet(list);
        String[] rid = (String[]) set.toArray(new String[0]);

        for (String data : rid) {
            inDto.put("MMRWDOCNO", data);
            //根据单号查询维修费用结算表数据
            List<Dto> mmrwData = this.baseMapper.getMmrwData(inDto);

            //根据订单上的法人组织字段mmrwlegal 从sys_org表找到ERP组织 根据ERP组织=MB001，从ERP的数据库DSCSYS的表DSCMB中抓到MB003的值
            Dto dbinfo1 = this.baseMapper.getDBinfo1(mmrwData.get(0).getString("MMRWLEGAL"));// 先查询biz_code_  因数据库排序问题  分成两个语句查询
            Dto dbinfo2 = this.baseMapper.getDBinfo2(dbinfo1.getString("BIZ_CODE"));

            String dbname = dbinfo2.getString("MB003").trim();
            if (dbname.isEmpty()) { //没查到目标数据库  添加失败
                JSONObject jo = new JSONObject();
                jo.put("ERPRESULT", "N");//同步结果  Y  N
                jo.put("MMRWDOCNO", mmrwData.get(0).getString("MMRWDOCNO"));//维修费用结算单号
                jo.put("ERPDOCNO", "");//erp单号
                jo.put("REASON", "目标数据库为空,添加失败");//失败原因
                json.add(jo);
                continue;
            }

            String docno = DateUtils.getDate("yyyyMMddSSS");
            String TB001 = "";
            try {
                int count = 1;
                for (Dto mmrw : mmrwData) {
                    //单身信息
                    Dto qDto = Dtos.newDto();
                    qDto.put("MB003", dbname);//目标数据库
                    //按法人组织抓取单号
                    Dto dhinfo = this.baseMapper.getGwaz(mmrw.getString("MMRWLEGAL"));
                    qDto.put("TB001", dhinfo.getString("GWAZ002"));
                    TB001 = dhinfo.getString("GWAZ002");
                    qDto.put("TB002", docno);
                    qDto.put("TB003", BigDecimal.valueOf(count));
                    qDto.put("TB004", mmrw.getString("MMRW001"));//品号
                    Dto tDto = Dtos.newDto();
                    tDto.put("GWEB002", mmrw.getString("MMRA001")); //客户编号
                    tDto.put("GWEB004", mmrw.getString("MMRW001"));
                    tDto.put("ENT", shiroUser.getDBC());
                    Dto result = this.baseMapper.getGwebData1(tDto);
                    if (result.size() == 0) {
                        result = this.baseMapper.getGwebData2(tDto);
                    }
                    qDto.put("TB005", result.getString("GWEB008"));//品名
                    qDto.put("TB006", result.getString("GWEB009"));//规格
                    qDto.put("TB007", result.getBigDecimal("MMRW003"));//数量
                    qDto.put("TB008", result.getString("MMRW002"));//单位
                    qDto.put("TB009", "");//库存数量
                    qDto.put("TB010", "");//单位成本
                    qDto.put("TB011", "");//金额
                    qDto.put("TB012", result.getString("MMRW005"));//转出库
                    qDto.put("TB013", "");//转入库
                    qDto.put("TB014", "********************");//批号
                    qDto.put("TB015", "");//有效日期
                    qDto.put("TB016", "");//附件日期
                    qDto.put("TB017", "");//备注
                    qDto.put("TB018", "N");//审核码
                    qDto.put("TB019", "");//预留字段
                    qDto.put("TB020", "");//小单位
                    qDto.put("TB021", "");//项目编号
                    qDto.put("TB022", "");//包装数量
                    qDto.put("TB023", "");//包装单位
                    qDto.put("TB024", "");//存储位置
                    qDto.put("TB025", "");//已销毁数量
                    qDto.put("TB026", "");//件装
                    qDto.put("TB027", "");//件数
                    qDto.put("TB028", "");//批号说明
                    qDto.put("TB029", "##########");//转出库位
                    qDto.put("TB030", "");//转入库位
                    qDto.put("TB031", "");//生产日期
                    qDto.put("TB032", "");
                    qDto.put("TB033", "");
                    qDto.put("TB034", "");
                    qDto.put("TB035", "");
                    qDto.put("TB036", "");
                    qDto.put("TB037", "");

                    this.baseMapper.insert_INVTB(qDto);

                    MmrwT mmrwT = new MmrwT();
                    mmrwT.setMMRWACTI("Z");
                    mmrwT.setMMRW013(docno);
                    mmrwT.setMMRW014(String.valueOf(count));
                    UpdateWrapper mmrwTUpdateWrapper = new UpdateWrapper();
                    mmrwTUpdateWrapper.eq("MMRWSEQ",result.getBigDecimal("mmrwseq"));
                    mmrwTUpdateWrapper.eq("MMRWENT",shiroUser.getDBC());
                    mmrwTUpdateWrapper.eq("MMRWDOCNO",data);
                    mmrwT.update(mmrwTUpdateWrapper);
                    count++;
                }

            } catch (Exception e) {
                JSONObject jo = new JSONObject();
                jo.put("ERPRESULT", "N");//同步结果  Y  N
                jo.put("MMRWDOCNO", mmrwData.get(0).getString("MMRWDOCNO"));//维修费用结算单号
                jo.put("ERPDOCNO", "");//erp单号
                jo.put("REASON", "添加INVTB表失败");//失败原因

                e.printStackTrace();

                Dto deltb = Dtos.newDto();
                deltb.put("MB003", dbname);
                deltb.put("TB001", TB001);
                deltb.put("TB002", docno);
                this.baseMapper.delete_INVTB(deltb);

                MmrwT mmrwT = new MmrwT();
                mmrwT.setMMRWACTI("Y");
                mmrwT.setMMRW013("");
                mmrwT.setMMRW014("");
                UpdateWrapper mmrwTUpdateWrapper = new UpdateWrapper();
                mmrwTUpdateWrapper.eq("MMRWENT",shiroUser.getDBC());
                mmrwTUpdateWrapper.eq("MMRWDOCNO",data);
                mmrwT.update(mmrwTUpdateWrapper);

                json.add(jo);
                continue;
            }

            try {
                //单头  订单信息
                Dto mmrwDto = mmrwData.get(0);
                Dto pDto = Dtos.newDto();
                pDto.put("MB003", dbname);//目标数据库
                //按法人组织抓取单号
                Dto dhinfo = this.baseMapper.getGwaz(mmrwDto.getString("MMRWLEGAL"));
                pDto.put("TA001", dhinfo.getString("GWAZ002"));
                pDto.put("TA002", docno);
                pDto.put("TA003", mmrwDto.getString("MMRWDOCDATE").replace("-", ""));//交易日期
                pDto.put("TA004", mmrwDto.getString("MMRW017_BIZ_CODE"));//部门编号 mmrw017对应的业务对照码
                pDto.put("TA005", mmrwDto.getString("MMRW015"));//备注
                pDto.put("TA006", "N"); //审核码
                pDto.put("TA007", "0"); //打印次数
                pDto.put("TA008", "1"); //工厂编号
                pDto.put("TA009", "11");  //单据性质码
                pDto.put("TA010", 0);  //件数
                pDto.put("TA011", 0);  //总数量
                pDto.put("TA012", 0);  //总金额
                pDto.put("TA013", "N"); //生成分录
                pDto.put("TA014", DateUtils.getDate("yyyyMMdd")); //单据日期
                pDto.put("TA015", ""); //审核者
                pDto.put("TA016", 0); //总包装数量
                pDto.put("TA017", "N"); //签核状态码
                pDto.put("TA018", ""); //海关手册
                pDto.put("TA019", ""); //审批意见
                pDto.put("TA020", ""); //不合格原因
                pDto.put("TA021", ""); //传送次数
                pDto.put("TA022", ""); //汇入日期
                pDto.put("TA023", ""); //门店编号
                pDto.put("TA024", ""); //对方汇出日期
                pDto.put("TA025", "1"); //单据来源
                pDto.put("TA026", "");
                pDto.put("TA027", "");
                pDto.put("TA028", "");
                pDto.put("TA029", "");
                pDto.put("TA030", "");
                pDto.put("TA031", "");
                pDto.put("TA032", "");// 人员编号 用户对应的业务对照码
                pDto.put("TA033", "");// 项目编号
                pDto.put("UDF01", "山东售后仓");
                pDto.put("UDF02", "领料");

                int row = this.baseMapper.insert_INVTA(pDto);

                String result = "N";
                if (row > 0) {
                    result = "Y";
                }

                JSONObject jo = new JSONObject();
                jo.put("ERPRESULT", result);//同步结果  Y  N
                jo.put("MMRWDOCNO", mmrwData.get(0).getString("MMRWDOCNO"));//维修费用结算单号
                jo.put("ERPDOCNO", docno);//erp单号
                jo.put("REASON", "");//失败原因
                json.add(jo);
            } catch (Exception e) {
                JSONObject jo = new JSONObject();
                jo.put("ERPRESULT", "N");//同步结果  Y  N
                jo.put("MMRWDOCNO", mmrwData.get(0).getString("MMRWDOCNO"));//维修费用结算单号
                jo.put("ERPDOCNO", docno);//erp单号
                jo.put("REASON", "添加INVTA表失败");//失败原因
                json.add(jo);

                e.printStackTrace();

                Dto deltb = Dtos.newDto();
                deltb.put("MB003", dbname);
                deltb.put("TB001", TB001);
                deltb.put("TB002", docno);
                this.baseMapper.delete_INVTB(deltb);

                MmrwT mmrwT = new MmrwT();
                mmrwT.setMMRWACTI("Y");
                mmrwT.setMMRW013("");
                mmrwT.setMMRW014("");
                UpdateWrapper mmrwTUpdateWrapper = new UpdateWrapper();
                mmrwTUpdateWrapper.eq("MMRWENT",shiroUser.getDBC());
                mmrwTUpdateWrapper.eq("MMRWDOCNO",data);
                mmrwT.update(mmrwTUpdateWrapper);

                //插入COPTA 失败  整张订单跳过 进行下个订单
                e.printStackTrace();
                continue;
            }
        }
        return json;
    }

    /**
     * 还原ERP订单
     */
    @Transactional
    public Dto restoreERP(Dto inDto) {
        Dto outDto = Dtos.newDto();
        ShiroUser shiroUser = ShiroKit.getUser();
        String[] selectionIds = inDto.getString("datas").split(",");
        List list = Arrays.asList(selectionIds);
        Set set = new HashSet(list);
        String[] rid = (String[]) set.toArray(new String[0]);
        String docno = "";
        int rows = 0;
        for (String data : rid) {
            inDto.put("MMRWDOCNO", data);

            //根据单号查询维修费用结算表数据
            List<Dto> mmrwData = this.baseMapper.getMmrwData(inDto);
            //根据订单上的法人组织字段mmrwlegal 从sys_org表找到ERP组织 根据ERP组织=MB001，从ERP的数据库DSCSYS的表DSCMB中抓到MB003的值
            Dto dbinfo1 = this.baseMapper.getDBinfo1(mmrwData.get(0).getString("MMRWLEGAL"));// 先查询biz_code_  因数据库排序问题  分成两个语句查询
            Dto dbinfo2 = this.baseMapper.getDBinfo2(dbinfo1.getString("BIZ_CODE"));
            String dbname = dbinfo2.getString("MB003").trim();

            inDto.put("MB003", dbname);
            inDto.put("MMRW013", mmrwData.get(0).getString("MMRW013"));
            Dto COPTAinfo = this.baseMapper.getINVTA(inDto);
            if (COPTAinfo.isEmpty()) {
                MmrwT mmrwT = new MmrwT();
                mmrwT.setMMRWACTI("Y");
                mmrwT.setMMRW013("");
                mmrwT.setMMRW014("");
                UpdateWrapper mmrwTUpdateWrapper = new UpdateWrapper();
                mmrwTUpdateWrapper.eq("MMRWENT",shiroUser.getDBC());
                mmrwTUpdateWrapper.eq("MMRWDOCNO",data);
                mmrwT.update(mmrwTUpdateWrapper);
                outDto.put("docno", "找不到对应ERP订单");
            } else if (COPTAinfo.getString("TA006").equals("N")) {
                Dto inDto2 = Dtos.newDto();
                inDto2.put("MB003", dbname);
                inDto2.put("TA006", "V");
                inDto2.put("TA002", COPTAinfo.getString("TA002"));
                this.baseMapper.updateINVTA(inDto2);

                MmrwT mmrwT = new MmrwT();
                mmrwT.setMMRWACTI("Y");
                mmrwT.setMMRW013("");
                mmrwT.setMMRW014("");
                UpdateWrapper mmrwTUpdateWrapper = new UpdateWrapper();
                mmrwTUpdateWrapper.eq("MMRWENT",shiroUser.getDBC());
                mmrwTUpdateWrapper.eq("MMRWDOCNO",data);
                mmrwT.update(mmrwTUpdateWrapper);
                outDto.put("docno", "操作成功");
            } else if (COPTAinfo.getString("TA006").equals("Y")) {
                outDto.put("docno", "ERP单据已经审核不能还原");
            }
            rows++;
        }
        return outDto;
    }

    @Transactional(readOnly = true)
    public List<Dto> getGwas001(Dto inDto) {
        List<Dto> listData = this.baseMapper.getGwas001(inDto);
        return listData;
    }

}
